package com.example.chapter03;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class AlertDialogActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView tv_alert;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_alert_dialog);

        findViewById(R.id.btn_alert).setOnClickListener(this);
        tv_alert = findViewById(R.id.tv_alert);
    }

    @Override
    public void onClick(View v) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("尊重的用户");
        builder.setMessage("你真的要卸载我吗");

        builder.setPositiveButton("残忍卸载",(dialog, which) -> {
            tv_alert.setText("虽然不舍，但是I开了");
        });
        builder.setNegativeButton("我在想想",(dialog, which) -> {
            tv_alert.setText("让我在陪你365个日夜");
        });

        AlertDialog dialog = builder.create();
        dialog.show();
    }
}